package com.tiancheng.trade.settlement.controller.admin;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.settlement.service.settlement.CommonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 公用controller
 */
@Controller
@RequestMapping("/admin/common")
@Validated
@Slf4j
public class CommonController {
    @Resource
    private CommonService commonService;
    @PostMapping("/upload")
    @ResponseBody
    public Result<?> upload(@RequestParam("file") MultipartFile file,@RequestParam("readType")String readType) {
        if (file.isEmpty()) {
            return Result.fail("上传失败,文件内容为空");
        }
        return commonService.fileUpload(file,readType);
    }
}
